//
//  DCHttpClient.h
//  DCProject
//
//  Created by bigbing on 2019/4/22.
//  Copyright © 2019 bigbing. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <MJExtension/MJExtension.h>

typedef NS_ENUM(NSInteger , DCHttpRequestType) {
    DCHttpRequestGet = 0, // get 请求
    DCHttpRequestPost,    // post 请求
    DCHttpRequestJsonPost, // json形式
};

NS_ASSUME_NONNULL_BEGIN

@interface DCHttpClient : NSObject

/*
 *  单列
 */
+ (DCHttpClient *) shareClient;


/*!
 *  @brief  设置基础的请求地址
 *
 *  @param  baseUrl   请求地址
 *
 */
+ (void)setBaseUrl:(NSString *)baseUrl;


/*!
 *  @brief  发送基础请求
 *
 *  @param  path     请求地址后缀
 *  @param  params   请求参数字典
 *  @param  method   请求方式
 *  @param  success  请求成功回调
 *  @param  failture  请求失败回调
 *
 */
- (void)requestWithPath:(NSString *)path
                 params:(NSDictionary *)params
             httpMethod:(DCHttpRequestType)method
                 sucess:(void (^)(NSURLSessionDataTask *task, id responseObject))success
               failture:(void (^)(NSURLSessionDataTask *task, NSError *error))failture;




/*!
 *  @brief  发送请求 带根地址
 *
 *  @param  baseUrl  根地址
 *  @param  path     请求地址后缀
 *  @param  params   请求参数字典
 *  @param  method   请求方式
 *  @param  success  请求成功回调
 *  @param  failture  请求失败回调
 *
 */
- (void)requestWithBaseUrl:(NSString *)baseUrl
                      path:(NSString *)path
                    params:(NSDictionary *)params
                httpMethod:(DCHttpRequestType)method
                    sucess:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                  failture:(void (^)(NSURLSessionDataTask *task, NSError *error))failture;



/*!
 *  @brief  上传图片(多图)
 *
 *  @param  path      请求地址后缀
 *  @param  images    图片数组，里面存放的是UIImage
 *  @param  fileName    后台接收名称
 *  @param  progress  上传进度回调
 *  @param  success   请求成功回调
 *  @param  failture   请求失败回调
 *
 */
- (void)requestUploadWithPath:(NSString *)path
                       images:(NSArray *)images
                     fileName:(NSString *)fileName
                     progress:(void(^)(NSProgress * uploadProgress))progress
                       sucess:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                     failture:(void (^)(NSURLSessionDataTask *task, NSError *error))failture;


/*!
 *  @brief  上传图片(单图)
 *
 *  @param  path      请求地址后缀
 *  @param  image    图片UIImage
 *  @param  fileName    后台接收名称
 *  @param  progress  上传进度回调
 *  @param  success   请求成功回调
 *  @param  failture   请求失败回调
 *
 */
- (void)requestUploadWithPath:(NSString *)path
                       image:(UIImage *)image
                     fileName:(NSString *)fileName
                     progress:(void(^)(NSProgress * uploadProgress))progress
                       sucess:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                     failture:(void (^)(NSURLSessionDataTask *task, NSError *error))failture;

// 文件下载
- (void)requestFileDownloadWithPath:(NSString *)path
                           progress:(void(^)(NSProgress * uploadProgress))progress
                           complete:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))complete;


@end

NS_ASSUME_NONNULL_END
